package com.ai.utils;


import java.io.UnsupportedEncodingException;

/**
 * @author wu.xiaofei15
 * @Description
 * @date 2020/4/24 10:01
 */
public class Base64Util {

    /**
     * 将byte转base64数组
     * @param binaryData
     * @return
     * @throws UnsupportedEncodingException
     */
    public static String encode(byte[] binaryData) throws UnsupportedEncodingException {
        return new String(com.ai.utils.Base64.encodeBase64(binaryData), "UTF-8");
    }

    /**
     * 将BASE64字符串恢复为二进制数据
     * @param base64String
     * @return
     * @throws UnsupportedEncodingException */
    public static byte[] decode(String base64String) throws UnsupportedEncodingException {
        return com.ai.utils.Base64.decodeBase64(base64String.getBytes("UTF-8"));
    }

}
